//
// Created by lewis on 2023/12/20.
//

//注意：需要在wsl中编译安装opencv环境以及vcxsrv软件，才可以使用本示例程序

#include <iostream>
#include <opencv2/opencv.hpp>

int main()
{
    printf("build_branch:\t%s\nbuild_sha1:\t%s\nbuild_time:\t%s %s\n",
           GIT_BRANCH_NAME, GIT_COMMIT_SHA1, __DATE__, __TIME__);
    cv::Mat frame;
    //
    std::string piplineCmd = "udpsrc port=14552 buffer-size=409600 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! capsfilter caps=\"video/x-raw,format=BGR\" ! videoconvert !  appsink sync=false";
    cv::VideoCapture cap(piplineCmd, cv::CAP_GSTREAMER);
    if(!cap.isOpened())
    {
        std::cout << "open gst pipeline failed!" << std::endl;
        return -1;
    }
    while(true)
    {
        cap >> frame;
        if (!frame.empty())
            cv::imshow("test_recv_image", frame);
            //cv::imwrite("test_img.jpg", frame);
        cv::waitKey(20);
    }
    return 0;
}

